<!-- 外卖门店详情 -->
<template name="shopdetailCom1">
	<view class="shopdetailCom shopdetailCom1">
		<view class="module_base module_info">
			<view class="module_title">配置信息</view>
			<view class="module_content info_content">
				<view class="info_eve">
					<view class="info_eve_title">基础支付</view>
					<view>{{basedata.basepay_bind_status?'已':'未'}}绑定</view>
				</view>
				<view class="info_eve">
					<view class="info_eve_title">外卖门店</view>
					<view>{{basedata.waimai_bind_status?'已':'未'}}绑定</view>
				</view>
				<view class="info_eve">
					<view class="info_eve_title">经营日期</view>
					<view>{{basedata.shopdateStr}}</view>
				</view>
				<view class="info_eve">
					<view class="info_eve_title">做菜时长</view>
					<view>{{basedata.stockup_time}}分钟</view>
				</view>
				<view class="info_eve">
					<view class="info_eve_title">接单设置</view>
					<view>{{basedata.is_auto_receive==1?'自动':'非自动'}}</view>
				</view>
				<view class="info_eve">
					<view class="info_eve_title">经营类型</view>
					<view>{{tagObj[basedata.waimai_tag]}}</view>
				</view>
				<view class="info_eve">
					<view class="info_eve_title">配送方式</view>
					<view>{{deliveryTypetext[basedata.delivery_type]}}</view>
				</view>
				<view class="info_eve">
					<view class="info_eve_title">起送价</view>
					<view>{{basedata.start_delivery_price}}</view>
				</view>
				<view class="info_eve">
					<view class="info_eve_title">餐盒费</view>
					<view>{{basedata.packing}}</view>
				</view>
				<view class="info_eve">
					<view class="info_eve_title">环境照</view>
					<view class="bluefont" @click="previewImg(basedata.merchant_pictures)">查看</view>
				</view>
			</view>
			<view class="module_title">门店信息</view>
			<view class="module_content info_content">
				<view class="info_eve">
					<view class="info_eve_title">门店联系电话</view>
					<view class="info_eve_phone" @click="makePhone(basedata.phone)">{{basedata2.phone}}</view>
				</view>
				<view class="info_eve info_address">
					<view class="info_eve_title">门店地址</view>
					<view>
						<image @click="navAddress()" src="../../../static/img/ic_location_2.png"></image>
					</view>
				</view>
				<view class="info_eve">
					<view>{{basedata2.address}}</view>
				</view>
				<view class="info_eve">
					<view class="info_eve_title">申请开通外卖</view>
					<view>{{basedata.first_apply_time}}</view>
				</view>
				<view class="info_eve">
					<view class="info_eve_title">审核通过时间</view>
					<view>{{basedata.first_audit_time}}</view>
				</view>
				<view class="info_eve">
					<view class="info_eve_title">外卖绑定时间</view>
					<view>{{basedata.bind_agency_time}}</view>
				</view>
				<view class="info_eve">
					<view class="info_eve_title">BD</view>
					<view>{{basedata.salesman}}</view>
				</view>
				<view class="info_eve">
					<view class="info_eve_title">总代</view>
					<view>{{basedata.general_agency}}</view>
				</view>
			</view>
		</view>
			
		<view class="module_base module_trade">
			<view class="module_title">外卖交易信息</view>
			<view class="module_content trade_content">
				<view>
					<view class="trade_num">{{orderdata.total.payment}}</view>
					<view class="trade_num">{{orderdata.total.num}}笔</view>
					<view>外卖订单交易</view>
				</view>
				<view>
					<view class="trade_num">{{orderdata.zq.payment}}</view>
					<view class="trade_num">{{orderdata.zq.num}}笔</view>
					<view>自取订单</view>
				</view>
				<view>
					<view class="trade_num">{{orderdata.zps.payment}}</view>
					<view class="trade_num">{{orderdata.zps.num}}笔</view>
					<view>自配送订单</view>
				</view>
				<view>
					<view class="trade_num">{{orderdata.ptps.payment}}</view>
					<view class="trade_num">{{orderdata.ptps.num}}笔</view>
					<view>平台配送订单</view>
				</view>
			</view>
		</view>
		<!-- <view style="height: 170rpx;"></view>
		<view class="module_base module_infoBtn">
			<view class="infoBtn">
				<button type="primary" @click="infoBtnfun()">跟进商户</button>
			</view>
		</view> -->
	</view>
</template>

<script>
	import { waimaishopdetailbase,waimaishoporder,shopdetailbase } from '../../../api/index.js'
	export default {
		name: "shopdetailCom1",
		data() {
			return {
				basedata:{},
				basedata2:{},
				orderdata:{
					"total": {
					    "payment": '',
					    "num": ''
					},
					"zps": {
					    "payment": '',
					    "num": ''
					},
					"ptps": {
					    "payment": '',
					    "num": ''
					},
					"zq": {
					    "payment": '',
					    "num": ''
					}
				},
				deliveryTypetext:{
					'0':'关闭',
					'1':'商户自配送',
					'2':'平台配送',
				},
				tagObj:{
					'1':'商超便利',
					'2':'蔬果肉禽',
					'3':'分切水果',
					'4':'药店',
					'5':'餐饮',
					'6':'其他',
					'7':'鲜花绿植'
				}
			}
		},
		mounted: function() {
			this.getWaimaishopdetailbase()
			this.getWaimaishoporder()
			this.getShopdetailbase()
		},
		props:{
			suid:''
		},
		methods: {
			//获取商户基本信息
			getWaimaishopdetailbase:function(){
				let that = this;
				waimaishopdetailbase({id:this.suid}).then((res) => {
					console.log(res)
					if(res.code == 0){
						let shopdateStr = '';
						if(!!res.data.shop_date){
							let shopdateArr = JSON.parse(res.data.shop_date);
							for (let shopDate of shopdateArr) {
								if(shopDate == 1){
									shopdateStr+="周一、"
								}else if(shopDate == 2){
									shopdateStr+="周二、"
								}else if(shopDate == 3){
									shopdateStr+="周三、"
								}else if(shopDate == 4){
									shopdateStr+="周四、"
								}else if(shopDate == 5){
									shopdateStr+="周五、"
								}else if(shopDate == 6){
									shopdateStr+="周六、"
								}else if(shopDate == 0){
									shopdateStr+="周日、"
								}
							}
							shopdateStr = shopdateStr.substr(0,shopdateStr.length-1)
						}
						
						
						that.basedata = res.data;
						that.basedata.shopdateStr = shopdateStr;
						// that.basedata = $.extend(that.basedata,res.data)
						that.$emit('editdataFun',that.basedata);
						
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				}).catch((e) => {
					console.log(e)
				})
			},
			//获取商户交易/积分信息
			getWaimaishoporder:function(){
				let that = this;
				waimaishoporder({id:this.suid}).then((res) => {
					console.log(res)
					if(res.code == 0){
						that.orderdata = res.data.data;
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				}).catch((e) => {
					console.log(e)
				})
			},
			//获取商户基本信息
			getShopdetailbase:function(){
				let that = this;
				shopdetailbase({id:this.suid}).then((res) => {
					console.log(res)
					if(res.code == 0){
						that.basedata2 = res.data;
						that.$emit('editdataFun',res.data);
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				}).catch((e) => {
					console.log(e)
				})
			},
			//图片放大
			previewImg:function(url){
				if(!url){
					uni.showToast({
						title: '暂无环境照',
						icon: 'none'
					})
					return ;
				}
				uni.previewImage({
					urls:[url]
				})
			},
			infoBtnfun:function(){
				uni.showToast({
					icon:'none',
					title:'功能正在开发中'
				})
				return ;
			},
			//跳转到高德地图
			navAddress:function(){
				let that = this;
				if(!that.basedata.longitude || !that.basedata.latitude){
					uni.showToast({
						title: "经纬度不能为空",
						icon: 'none'
					})
					return ;
				}
				if(!that.basedata.address){
					uni.showToast({
						title: "地址不能为空",
						icon: 'none'
					})
					return ;
				}
				cm.jumpMap({
					longitude:that.basedata.longitude,
					latitude:that.basedata.latitude,
					destination:that.basedata.address
				})
			},
			//拨打电话
			makePhone:function(phone){
				cm.makePhoneCall({
					phone:phone
				});
			}
		},
		components: {
			
		}
	}
</script>

<style lang="scss" scoped>
	@import './shopdetailCom.scss';
	.module_infoBtn{
		padding: 30rpx;
		background-color: #fff;
	}
</style>
